<template>
    <el-table :data="props.tableData" style="width: 100%" @selection-change="selectchange">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="fileName" label="文件名">
            <template #default="scope">

                <div style="display: flex;justify-content: space-between;">
                    <div>{{ scope.row.fileName }}</div>
                    <div class="cz">
                        <div style="display: flex;align-items: center;cursor:pointer">
                            <div @click="copylink(scope.row)"
                                style="display: flex;align-items: center;cursor:pointer;margin-right: 20px;color:#409eff">
                                <el-icon>
                                    <Link />
                                </el-icon>
                                复制链接
                            </div>
                            <div @click="resetshare(scope.row)"
                                style="display: flex;align-items: center;cursor:pointer;margin-right: 20px;color:#409eff">
                                <el-icon>
                                    <Eleme />
                                </el-icon>
                                取消分享
                            </div>

                        </div>
                    </div>
                </div>
            </template>

        </el-table-column>

        <el-table-column prop="shareTime" label="分享时间" width="200" />
        <el-table-column prop="expireTime" label="失效时间" width="200" />
        <el-table-column prop="showCount" label="浏览次数" width="200" />


    </el-table>


</template>
<script setup>
import { ElMessage } from 'element-plus'
import { ref } from 'vue';
const props = defineProps(["tableData"])
const emit = defineEmits(["selectlist", "reset"])
const tableData = ref([])
const selectchange = (e) => {
    emit("selectlist", e)

}
const resetshare = (row) => {
    emit("reset", row)
}
const copylink = (row) => {
    console.log(row)
    navigator.clipboard.writeText("链接:" + "http://localhost:1001/watchshare?path=" + row.shareId + ',提取码:' + row.code).then(() => {
        ElMessage({
            type: "success",
            message: "成功"
        })
    })

}
</script>